package swtElements;

import globalOperations.MarkupMethods;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.GridData;

public class MyBrowser {
	
	Browser browser;
	
	public MyBrowser(MyComposite client, String html, int minHeight, boolean parse){
		if(minHeight == 0){
			this.browser = new Browser(client.getComposite(), SWT.NONE);
			this.browser.setLayoutData(new GridData(GridData.FILL_BOTH));
			this.browser.setText(MarkupMethods.parseMarkUpToHTML(html));
		}else{
			GridData gridData = new GridData(GridData.FILL_BOTH);
			gridData.minimumHeight = minHeight;
			this.browser = new Browser(client.getComposite(), SWT.NONE);
			this.browser.setLayoutData(gridData);
			if(parse){
				browser.setText(MarkupMethods.parseMarkUpToHTML(html));
			}else{
				browser.setText(html);
			}
		}
	}

	public void setText(String html) {
		this.browser.setText(html);
	}
}
